package main

import (
	"fmt"
	"sync"
)

var wg sync.WaitGroup

func wirter(ch chan int) {
	defer wg.Done()
	defer close(ch)
	for i := 0; i < 10; i++ {
		ch <- i
	}

}

func reader(ch chan int) {
	i := <-ch
	fmt.Println("读取到数据：", i)
	wg.Done()
}

func main() {

	ch := make(chan int, 0)
	wg.Add(1)
	go wirter(ch)

	for i := 0; i < 10; i++ {
		wg.Add(1)
		go reader(ch)
	}
	wg.Wait()
}
